using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace GodSoft.Models.Mapping
{
    public class CollectorMap : EntityTypeConfiguration<Collector>
    {
        public CollectorMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.IP)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Collector_Heartbeat_Packets)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Registration_Packet)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Notes)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Collector");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.TypeID).HasColumnName("TypeID");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.IP).HasColumnName("IP");
            this.Property(t => t.Port).HasColumnName("Port");
            this.Property(t => t.Collector_Heartbeat_Packets).HasColumnName("Collector_Heartbeat_Packets");
            this.Property(t => t.Heartbeat_Interval).HasColumnName("Heartbeat_Interval");
            this.Property(t => t.Registration_Packet).HasColumnName("Registration_Packet");
            this.Property(t => t.Collector_Status).HasColumnName("Collector_Status");
            this.Property(t => t.Enable).HasColumnName("Enable");
            this.Property(t => t.Notes).HasColumnName("Notes");

            // Relationships
            this.HasRequired(t => t.DeviceType)
                .WithMany(t => t.Collectors)
                .HasForeignKey(d => d.TypeID);

        }
    }
}
